<!DOCTYPE html>
<html>

    <head>
        <meta charset="UTF-8">
        <title></title>
        <meta name="viewport" content="initial-scale=1.0, maximum-scale=1.0, user-scalable=no" />
        <script type="text/javascript" src="js/jquery-1.12.0.min.js"></script>
        <style type="text/css">
            input{
                width: 100%;
                height: 50px;
                background-color: darkgreen;
                position: fixed;
                left: 0;
                bottom: 0;
            }
            .lo{
                width: 300px;
                height: 50px;
                background-color: darkcyan;
                text-align: center;
                line-height: 50px;
            }
            .xxx{
                width: 50px;
                height: 1000px;
                background-color: darkgrey;
            }
        </style>
    </head>

    <body>
<div class="lo">点这里</div>
<div class="xxx"></div>
        <input type="text" id="txt" />
        <div id="dv"></div>
        <script>


    $(".lo").click(function(){
        $("#txt").css({position:"relative"})
        $("#txt").focus();
        /*setTimeout(function(){
            target.scrollIntoViewIfNeeded();
            //target.scrollIntoView(true);
            console.log('scrollIntoViewIfNeeded');
        },00);*/
    })

    $('input[type="text"],textarea').on('focus', function () {

        var target = this;
        setTimeout(function(){
            target.scrollIntoViewIfNeeded();
            //target.scrollIntoView(true);
            console.log('scrollIntoViewIfNeeded');
        },200);
    });









    /*      
    var clientHeight = document.body.clientHeight;
    var _focusElem = null; //输入框焦点
    //利用捕获事件监听输入框等focus动作
    document.body.addEventListener("focus", function(e) {
        _focusElem = e.target || e.srcElement;
       console.log(111)
    }, true);
    //因为存在软键盘显示而屏幕大小还没被改变，所以以窗体（屏幕显示）大小改变为准
    window.addEventListener("resize", function() {
        alert(222)
        setTimeout(function(){
            _focusElem.scrollIntoViewIfNeeded();
            //console.log('scrollIntoViewIfNeeded');
        },200);
            //焦点元素滚动到可视范围的底部(false为底部)
       // _focusElem.scrollIntoView(true);

    });*/

//          setTimeout(function(){
//              target.scrollIntoViewIfNeeded();
//              console.log('scrollIntoViewIfNeeded');
//          },200);
//          


        </script>

    </body>

</html>